
// <copyright file="DynamicXmlWriteHelperTests.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   Class DynamicXmlWriteHelperTests.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Tests.Reflection
{
    using System.IO;
    using System.Xml;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using SubhadraSolutions.Sharp.Utils.Reflection;
    using SubhadraSolutions.Sharp.Utils.Tests.DummyClasses;

    /// <summary>
    ///     Class DynamicXmlWriteHelperTests.
    /// </summary>
    [TestClass]
    public class DynamicXmlWriteHelperTests
    {
        #region Public Methods and Operators

        /// <summary>
        ///     Tests this instance.
        /// </summary>
        [TestMethod]
        public void Test()
        {
            const string expectedXml = "<?xml version=\"1.0\" encoding=\"utf-16\"?><Employee DateOfBirth=\"5/1/1979 12:00:00 AM\" DateOfJoin=\"4/1/2013 12:00:00 AM\" EmploymentType=\"FullTime\" FirstName=\"SubhadraSolutionsmanya\" Id=\"0\" LastName=\"Oruganti\" />";
            Employee e = Employee.BuildDummyEmployee();
            string actualXml = null;
            using (var sw = new StringWriter())
            {
                using (XmlWriter xw = XmlWriter.Create(sw))
                {
                    xw.WriteStartElement("Employee");
                    DynamicXmlWriteHelper<Employee>.Write(e, xw);
                    xw.WriteEndElement();
                }

                actualXml = sw.ToString();
            }

            Assert.IsTrue(actualXml == expectedXml);
        }

        #endregion Public Methods and Operators
    }
}
